package com.nd.test.service;

import java.util.List;
import java.util.Date;

import model.po.CouponsCategory;
import com.nd.test.vo.CouponsCategoryVo;
import com.nd.test.repository.CouponsCategoryRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**   
 * Create by apisdk 
 */
@Service
public class CouponsCategoryService {
	@Autowired
	private CouponsCategoryRepository couponsCategoryRepository;

	/**
	* @description create model
	* @return
	*/
	public CouponsCategoryVo createCouponsCategory(CouponsCategoryVo couponsCategoryVo) throws Exception {
		CouponsCategory couponsCategory = new CouponsCategory();
		BeanUtils.copyProperties(couponsCategoryVo, couponsCategory);
		couponsCategory =  couponsCategoryRepository.save(couponsCategory);
		BeanUtils.copyProperties(couponsCategory, couponsCategoryVo);
		return couponsCategoryVo;
	}

	/**
	* @description get model through id
	* @return
	*/
	public List<CouponsCategoryVo></Vo> getCouponsCategoryByExample(CouponsCategoryVo couponsCategoryVo){
		CouponsCategory couponsCategory = new CouponsCategory();
		BeanUtils.copyProperties(couponsCategoryVo, couponsCategory);
	}

	/**
	* @description update model through id
	* @return
	*/
	public CouponsCategoryVo updateCouponsCategoryById(@PathVariable String id,@RequestBody CouponsCategoryVo couponsCategoryVo){
		//TODO to finish update code
		return couponsCategoryVo;
	}

	/**
	* @description delete model through id
	* @return
	*/
	public void deleteCouponsCategoryById(@PathVariable String id){
		CouponsCategory couponsCategory =  couponsCategoryRepository.findOne(id);
		if(couponsCategory!=null){
			couponsCategoryRepository.delete(couponsCategory);
		}
		return;
	}

}
